home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / MoreFiles 1.3.1 / MoreDesktopMgr.p < prev    next >
Encoding:
Text File  |  1995-06-08  |  9.6 KB  |  243 lines  |  [TEXT/MWPS]

  1. UNIT MoreDesktopMgr;
  2.  
  3. {    Apple Macintosh Developer Technical Support                                }
  4. {                                                                            }
  5. {    A collection of useful high-level Desktop Manager routines.                }
  6. {    If the Desktop Manager isn't available, use the Desktop file            }
  7. {    for 'read' operations.                                                    }
  8. {                                                                            }
  9. {    We do more because we can...                                            }
  10. {                                                                            }
  11. {    by Jim Luther and Nitin Ganatra, Apple Developer Technical Support        }
  12. {                                                                            }
  13. {    by Jim Luther, Apple Developer Technical Support                        }
  14. {                                                                            }
  15. {    File:        MoreDesktopMgr.p                                            }
  16. {                                                                            }
  17. {    Copyright © 1992-1995 Apple Computer, Inc.                                }
  18. {    All rights reserved.                                                    }
  19. {                                                                            }
  20. {    You may incorporate this sample code into your applications without        }
  21. {    restriction, though the sample code has been provided "AS IS" and the    }
  22. {    responsibility for its operation is 100% yours.  However, what you are    }
  23. {    not permitted to do is to redistribute the source as "DSC Sample Code"    }
  24. {    after having made changes. If you're going to re-distribute the source,    }
  25. {    we require that you make it clear in the source that the code was        }
  26. {    descended from Apple Sample Code, but that you've made changes.            }
  27.  
  28.  
  29. INTERFACE
  30.  
  31. USES
  32.     Files;
  33.  
  34. {***************************************************************************}
  35.  
  36.  
  37.     FUNCTION DTOpen (volName: StringPtr;
  38.                                     vRefNum: Integer;
  39.                                     VAR dtRefNum: Integer;
  40.                                     VAR newDTDatabase: Boolean): OSErr;
  41. {    The DTOpen function opens a volume's desktop database. It returns        }
  42. {    the reference number of the desktop database and indicates if the        }
  43. {    desktop database was created as a result of this call (if it was        }
  44. {    created, then it is empty).                                                }
  45. {                                                                            }
  46. {    volName            input:    A pointer to the name of a mounted volume        }
  47. {                            or nil.                                            }
  48. {    vRefNum            input:    Volume specification.                            }
  49. {    dtRefNum        output:    The reference number of Desktop Manager's        }
  50. {                            desktop database on the specified volume.        }
  51. {    newDTDatabase    output:    true if the desktop database was created as a    }
  52. {                            result of this call and thus empty.                }
  53. {                            false if the desktop database was already        }
  54. {                            created, or if it could not be determined if it    }
  55. {                            was already created.                            }
  56.  
  57.  
  58. {***************************************************************************}
  59.  
  60.  
  61.     FUNCTION DTGetAPPL (volName: StringPtr;
  62.                                     vRefNum: Integer;
  63.                                     creator: OSType;
  64.                                     VAR applVRefNum: Integer;
  65.                                     VAR applParID: LongInt;
  66.                                     VAR applName: Str255): OSErr;
  67. {    The DTGetAPPL function finds an application (file type 'APPL') with        }
  68. {    the specified creator on the specified volume. It first tries to get    }
  69. {    the application mapping from the desktop database. If that fails, then    }
  70. {    it tries to find an application with the specified creator using        }
  71. {    the File Manager's CatSearch routine. If that fails, then it tries to    }
  72. {    find an application in the Desktop file.                                }
  73. {                                                                            }
  74. {    volName        input:    A pointer to the name of a mounted volume            }
  75. {                        or nil.                                                }
  76. {    vRefNum        input:    Volume specification.                                }
  77. {    creator        input:    The file's creator type.                            }
  78. {    applVRefNum    output:    The volume reference number of the volume the        }
  79. {                        application is on.                                    }
  80. {    applParID    output:    The parent directory ID of the application.            }
  81. {    applName    output:    The name of the application.                        }
  82.  
  83.  
  84. {***************************************************************************}
  85.  
  86.  
  87.     FUNCTION FSpDTGetAPPL (volName: StringPtr;
  88.                                     vRefNum: Integer;
  89.                                     creator: OSType;
  90.                                     VAR spec: FSSpec): OSErr;
  91. {    The FSpDTGetAPPL function finds an application (file type 'APPL') with    }
  92. {    the specified creator on the specified volume. It first tries to get    }
  93. {    the application mapping from the desktop database. If that fails, then    }
  94. {    it tries to find an application with the specified creator using        }
  95. {    the File Manager's CatSearch routine. If that fails, then it tries to    }
  96. {    find an application in the Desktop file.                                }
  97. {                                                                            }
  98. {    volName        input:    A pointer to the name of a mounted volume            }
  99. {                        or nil.                                                }
  100. {    vRefNum        input:    Volume specification.                                }
  101. {    creator        input:    The file's creator type.                            }
  102. {    spec        output:    FSSpec record containing the application name and    }
  103. {                        location.                                            }
  104.  
  105.  
  106. {***************************************************************************}
  107.  
  108.  
  109.     FUNCTION DTGetIcon (volName: StringPtr;
  110.                                     vRefNum: Integer;
  111.                                     iconType: Integer;
  112.                                     fileCreator: OSType;
  113.                                     fileType: OSType;
  114.                                     VAR iconHandle: Handle): OSErr;
  115. {    The DTGetIcon function retrieves the specified icon and returns it in    }
  116. {    a newly created handle. The icon is retrieves from the Desktop Manager    }
  117. {    or if the Desktop Manager is not available, from the Finder's Desktop    }
  118. {    file. Your program is responsible for disposing of the handle when it    }
  119. {    is done using the icon.                                                    }
  120. {                                                                            }
  121. {    volName        input:    A pointer to the name of a mounted volume            }
  122. {                        or nil.                                                }
  123. {    vRefNum        input:    Volume specification.                                }
  124. {    iconType    input:    The icon type as defined in Files.h. Valid values    }
  125. {                        are:                                                }
  126. {                            kLargeIcon                                        }
  127. {                            kLarge4BitIcon                                    }
  128. {                            kLarge8BitIcon                                    }
  129. {                            kSmallIcon                                        }
  130. {                            kSmall4BitIcon                                    }
  131. {                            kSmall8BitIcon                                    }
  132. {    fileCreator    input:    The icon's creator type.                            }
  133. {    fileType    input:    The icon's file type.                                }
  134. {    iconHandle    output:    A Handle containing the newly created icon.            }
  135.  
  136.  
  137. {***************************************************************************}
  138.  
  139.  
  140.     FUNCTION DTSetComment (vRefNum: Integer;
  141.                                     dirID: LongInt;
  142.                                     name: StringPtr;
  143.                                     comment: Str255): OSErr;
  144. {    The DTSetComment function sets a file or directory's Finder comment        }
  145. {    field. The volume must support the Desktop Manager because you only        }
  146. {    have read access to the Desktop file.                                    }
  147. {                                                                            }
  148. {    vRefNum    input:    Volume specification.                                    }
  149. {    dirID    input:    Directory ID.                                            }
  150. {    name    input:    Pointer to object name, or nil when dirID                }
  151. {                    specifies a directory that's the object.                }
  152. {    comment    input:    The comment to add. Comments are limited to 200            }
  153. {                    characters; longer comments are truncated.                }
  154.  
  155.  
  156. {***************************************************************************}
  157.  
  158.  
  159.     FUNCTION FSpDTSetComment ({CONST}VAR spec: FSSpec;
  160.                                     comment: Str255): OSErr;
  161. {    The FSpDTSetComment function sets a file or directory's Finder comment    }
  162. {    field. The volume must support the Desktop Manager because you only        }
  163. {    have read access to the Desktop file.                                    }
  164. {                                                                            }
  165. {    spec    input:    An FSSpec record specifying the file or directory.        }
  166. {    comment    input:    The comment to add. Comments are limited to 200            }
  167. {                    characters; longer comments are truncated.                }
  168.  
  169.  
  170. {***************************************************************************}
  171.  
  172.  
  173.     FUNCTION DTGetComment (vRefNum: Integer;
  174.                                     dirID: LongInt;
  175.                                     name: StringPtr;
  176.                                     VAR comment: Str255): OSErr;
  177. {    The DTGetComment function gets a file or directory's Finder comment        }
  178. {    field (if any) from the Desktop Manager or if the Desktop Manager is    }
  179. {    not available, from the Finder's Desktop file.                            }
  180. {                                                                            }
  181. {    vRefNum    input:    Volume specification.                                    }
  182. {    dirID    input:    Directory ID.                                            }
  183. {    name    input:    Pointer to object name, or nil when dirID                }
  184. {                    specifies a directory that's the object.                }
  185. {    comment    output:    A Str255 where the comment is to be returned.            }
  186.  
  187.  
  188. {***************************************************************************}
  189.  
  190.  
  191.     FUNCTION FSpDTGetComment ({CONST}VAR spec: FSSpec;
  192.                                     VAR comment: Str255): OSErr;
  193. {    The FSpDTGetComment function gets a file or directory's Finder comment    }
  194. {    field (if any) from the Desktop Manager or if the Desktop Manager is    }
  195. {    not available, from the Finder's Desktop file.                            }
  196. {                                                                            }
  197. {    spec    input:    An FSSpec record specifying the file or directory.        }
  198. {    comment    output:    A Str255 where the comment is to be returned.            }
  199.  
  200.  
  201. {***************************************************************************}
  202.  
  203.  
  204.     FUNCTION DTCopyComment (srcVRefNum: Integer;
  205.                                     srcDirID: LongInt;
  206.                                     srcName: StringPtr;
  207.                                     dstVRefNum: Integer;
  208.                                     dstDirID: LongInt;
  209.                                     dstName: StringPtr): OSErr;
  210. {    The DTCopyComment function copies the file or folder comment from the    }
  211. {    source to the destination object.  The destination volume must support    }
  212. {    the Desktop Manager because you only have read access to the Desktop    }
  213. {    file.                                                                    }
  214. {                                                                            }
  215. {    srcVRefNum    input:    Source volume specification.                        }
  216. {    srcDirID    input:    Source directory ID.                                }
  217. {    srcName        input:    Pointer to source object name, or nil when srcDirID    }
  218. {                        specifies a directory that's the object.            }
  219. {    dstVRefNum    input:    Destination volume specification.                    }
  220. {    dstDirID    input:    Destination directory ID.                            }
  221. {    dstName        input:    Pointer to destination object name, or nil when        }
  222. {                        dstDirID specifies a directory that's the object.    }
  223.  
  224.  
  225. {***************************************************************************}
  226.  
  227.  
  228.     FUNCTION FSpDTCopyComment ({CONST}VAR srcSpec: FSSpec;
  229.                                     {CONST}VAR dstSpec: FSSpec): OSErr;
  230. {    The FSpDTCopyComment function copies the desktop database comment from    }
  231. {    the source to the destination object.  Both the source and the            }
  232. {    destination volumes must support the Desktop Manager.                    }
  233. {                                                                            }
  234. {    srcSpec        input:    An FSSpec record specifying the source object.        }
  235. {    dstSpec        input:    An FSSpec record specifying the destination object.    }
  236.  
  237.  
  238. {***************************************************************************}
  239.  
  240.  
  241. IMPLEMENTATION
  242.  
  243. END.